import { createRouter, createWebHistory } from 'vue-router'
import Test from '@/views/test'

// 公共布局页面(父路由)
const Layout = () => import('@/views/Layout')
// 导入子路由页面
const Home = () => import('@/views/Home')
// 分类页面
const CateGory = () => import('@/views/Category')
// 商品详情页面
const Detail = () => import('@/views/Detail')

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/', // 地址和父地址一样默认加载
        component: Home
      },
      {
        path: 'category/:id',
        component: CateGory
      },
      {
        path: '/detail/:id',
        component: Detail
      }
    ]
  },
  {
    path: '/test',
    component: Test
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
